﻿@model IEnumerable<Api.Model.Project>
@{Layout = "~/Areas/Admin/Views/Shared/_AdminLayout.cshtml";}
@section seo{
    <title>項目列表</title>
}

@section script{
    <script>
        $(function () {
            window.form = $('#form1');
            window.deleteUrl = '@Url.Action("Delete","Project")';
        });
        //删除记录
        function deleteIds() {
            var chkboxs = $("input:checked[type=checkbox]", $('#tbody'));

            if (chkboxs.length == 0) {
                msgBox.showMsgErr("請選擇一項");
                return false;
            }
            var obj = window.confirm("確定刪除嗎");
            var data = $(form).serialize();
            if (obj) {
                $.post(deleteUrl, data, function (ajaxMsg) {
                    msgBox.showMsg(ajaxMsg);
                    $.each(chkboxs, function () {
                        $(this).parents('tr').remove();
                        $('#ulLeftMenu').find('[pid='+$(this).val()+']').remove();
                    })

                });
            }
        }

        //修改tbody中tr的样式
        function changeTrClass() {
            $('#tbody tr').each(function (i, element) {
                if (i % 2 == 0) {
                    $(element).addClass('zxbejing');
                }
            });
        };
    </script>
}

<form id="form1">
    @Html.AntiForgeryToken()
    <!--左邊菜單--開始-->
    @Html.Partial("_leftMenu")
    <!--左邊菜單--結束-->

    <div class="shanpin_right">
        <!--搜索--B-->
        <div class="sptanst">
            <h2><span class="product_manage">網站列表</span></h2>
            <div class="table-responsive">
                <table width="100%" border="0" cellspacing="0" cellpadding="0" class="table-bordered">
                    <tbody>
                        <tr>
                            <td>
                                <div class="zhengjh">
                                    <table width="100%">
                                        <tbody>
                                            <tr>
                                                <td></td>
                                                <td colspan="2"></td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </td>
                            <td valign="top">
                                @*<div class="newsspindss" style="float: left">
                                        <a id="lbSearch">
                                            <span class="glyphicon glyphicon-search forn30"></span>
                                        </a>
                                    </div>*@
                                <div class="newsspind" style="float: right;">
                                    <a href="@Url.Action("Create","Project")" title="添加項目">
                                        <span class="glyphicon glyphicon-plus-sign forn30"></span>
                                    </a>
                                </div>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
        <!--搜索--E-->
        <!--内容--B-->
        <div class="tmbdliebiao" style="width: 100%">
            <div class="table-responsive">
                <table width="100%" border="0" cellspacing="0" cellpadding="0" class="table table-bordered uytak">
                    <thead>
                        <tr style="border-bottom: 2px solid #D1D1D1;">
                            <td width="9%">
                                <input type="checkbox" onclick="selectBox(this)" />
                                <a id="btnDel" onclick="return deleteIds()">
                                    <span class="glyphicon glyphicon-trash"></span>
                                </a>
                            </td>

                            <td width="9%">
                                <b class="">
                                    <span>名稱</span>
                                    <span name="" class=""></span>
                                </b>
                            </td>
                            <td width="9%">
                                <b class="">
                                    <span>創建時間</span>
                                    <span name="" class=""></span>
                                </b>
                            </td>
                        </tr>
                    </thead>
                    <tbody id="tbody">
                        @foreach (var project in Model)
                        {
                            <tr>
                                <td>
                                    <input type="checkbox" value="@project.Id" name="Ids" />
                                    <a href="@Url.Action("Edit", new {Id = project.Id})">
                                        <span class="glyphicon glyphicon-pencil"></span>
                                    </a>
                                </td>
                                <td>
                                    @Html.CusRaw(project.Name)
                                </td>
                                <td>
                                    @Html.CusRaw(project.CreateDate)
                                </td>
                            </tr>
                        }
                    </tbody>
                </table>

                <!--分頁--B-->
                <div class="container-fluid">
                    <div class="row-fluid">
                        <div class="span12">
                            <div id="pagination-demo" class="pagination"></div>
                        </div>
                    </div>
                </div>
                <!--分頁--E-->
            </div>
        </div>
        <!--内容--E-->
    </div>
</form>